<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    let a = [1,2,3, [1,2,3, [1,2,3]]]
    // 变成
    // let b = [1,2,3,1,2,3,1,2,3]
    function flat(arr = [], result = []) {
        arr.forEach((item) => {
            if (Array.isArray(item)) {
                result = [...result, ...flat(item)];
            } else {
                result.push(item);
            }
        })
        return result;
    }

    console.log(flat(a))
</script>
</body>
</html>
